
	.code32
	.global main
#	.extern kmain
main:
#	jmp .

	call kmain
	hlt

	.global newgdt
newgdt:	
	movl $0xffff,%eax
	movl $gdt,%eax         #$ must be here! what the HELL?
	subl $0xC0000000, %eax
#	jmp .
	movl %eax,(gdt_48+2)

	
	lgdt gdt_48
	
	
	ljmpl $0b10000,$flush
flush:
#	jmp .
	mov $0x18,%ax
	mov %ax,%ds
	mov %ax,%es
	mov %ax,%fs
	mov %ax,%gs
	movl $gdt_48, %eax
	subl $0xC0000000, %eax
	lgdtl (%eax)
	ret
	mov $0b11000,%ax
	
	mov %ax,%ss
	mov $0x1000000,%eax
	mov %eax,%esp
	mov $0x18,%ax
#	shl $3,%ax
	mov %ax,%ds
	#0xC0000000->0x00000000
	ret


	movl $(0xb8000+80*24+150),%edi
	movb $'a',%ds:(%edi)
	call kmain	
	movb $'c',%ds:(%edi)
	jmp .
.data
gdt:
	.quad 0x0
	.word 0xffff,0x8000,0x920b,0x00cf #video
	.word 0xffff,0x0000,0x9a00,0x00cf #code
	.word 0xffff,0x0000,0x9200,0x00cf #data
	.word 0xffff,0x0000,0x9200,0x01cf

gdt_48:
	.word gdt_48-gdt-1
	.long 0
.bss
	nop
	

	
